home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-01-19 | 49.9 KB | 1,628 lines |
- Newsgroups: comp.sources.misc
- subject: v10i018: PCcurses v.1.4 part 4 of 7
- from: bl@infovox.se (Bj|rn Larsson)
- Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
-
- Posting-number: Volume 10, Issue 18
- Submitted-by: bl@infovox.se (Bj|rn Larsson)
- Archive-name: pccurses14/part04
-
- # ----------------------------- cut here -----------------------------
- #! /bin/sh
- # This is a shell archive. Remove anything before the `cut' line,
- # then unpack by saving it into a file and typing `sh file'. The
- # archive ends by exit(0), so don't worry about trailing junk.
- #
- # (This is archive 4 in a series of 7).
- #
- # Contents:
- #
- # charget.c
- # cursesio.asm
- # makefile.68
- # prntscan.c
- # update.c
- #
- # Wrapped by USER@MS-DOS --- Sun Jan 14 14:02:40 1990
- #
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f charget.c -a "${1}" != "-c" ; then
- echo Will not over-write existing file \"charget.c\"
- else
- echo Extracting - \"charget.c\"
- sed "s/^X//" >charget.c <<'END_OF_charget.c'
- X/****************************************************************/
- X/* Getch() routines of the PCcurses package */
- X/* */
- X/****************************************************************/
- X/* This version of curses is based on ncurses, a curses version */
- X/* originally written by Pavel Curtis at Cornell University. */
- X/* I have made substantial changes to make it run on IBM PC's, */
- X/* and therefore consider myself free to make it public domain. */
- X/* Bjorn Larsson (bl@infovox.se) */
- X/****************************************************************/
- X/* 1.4: Routines that ended in while-loops now end */
- X/* with return(ERR) to avoid compiler warnings. */
- X/* Use of short wherever possible. Portability */
- X/* improvements: 900114 */
- X/* 1.3: MSC -W3, Turbo'C' -w -w-pro checkes: 881005 */
- X/* 1.2: #undef:ine of getch now covers all the file, to */
- X/* make sure this module's getch() calls go to DOS, */
- X/* not to the PCCurses 'getch()' function. Fixed */
- X/* thanks to N.D. Pentcheff: 881002 */
- X/* 1.1: Bug fixes: call to _curseskeytest() changed */
- X/* _curseskeytst(). Test of that routine also */
- X/* lacked () in one place: 870907 */
- X/* 1.0: Release: 870515 */
- X/****************************************************************/
- X
- X#include <curses.h>
- X#include <curspriv.h>
- X
- X#undef getch /* We use MSC getch() below */
- X#undef ungetch
- X
- X#include <conio.h>
- X
- Xstatic short rawgetch(); /* get raw char via BIOS */
- Xstatic short sysgetch(); /* get char via system */
- Xstatic short validchar(); /* keypad xlate and char check */
- X
- Xchar _curses_charget_rcsid[] = "@(#)charget.c v.1.4 - 900114";
- X
- Xstatic short buffer[_INBUFSIZ]; /* character buffer */
- Xstatic short pindex = 0; /* putter index */
- Xstatic short gindex = 1; /* getter index */
- Xstatic WINDOW *w; /* to reduce stack usage */
- Xstatic short ungind = 0; /* wungetch() push index */
- Xstatic short ungch[NUNGETCH]; /* array of ungotten chars */
- X
- X/* Table for key code translation of function keys in keypad mode */
- X/* These values are for strict IBM keyboard compatibles only */
- X
- Xstatic short kptab[] =
- X {
- X 0x3b,KEY_F(1), 0x3c,KEY_F(2), 0x3d,KEY_F(3), 0x3e,KEY_F(4),
- X 0x3f,KEY_F(5), 0x40,KEY_F(6), 0x41,KEY_F(7), 0x42,KEY_F(8),
- X 0x43,KEY_F(9), 0x44,KEY_F(10), 0x47,KEY_HOME, 0x48,KEY_UP,
- X 0x49,KEY_PPAGE, 0x4b,KEY_LEFT, 0x4d,KEY_RIGHT, 0x4f,KEY_LL,
- X 0x50,KEY_DOWN, 0x51,KEY_NPAGE, 0x52,KEY_IC, 0x53,KEY_DC,
- X 0x54,KEY_F(11), 0x55,KEY_F(12), 0x56,KEY_F(13), 0x57,KEY_F(14),
- X 0x58,KEY_F(15), 0x59,KEY_F(16), 0x5a,KEY_F(17), 0x5b,KEY_F(18),
- X 0x5c,KEY_F(19), 0x5d,KEY_F(20), 0x5e,KEY_F(21), 0x5f,KEY_F(22),
- X 0x60,KEY_F(23), 0x61,KEY_F(24), 0x62,KEY_F(25), 0x63,KEY_F(26),
- X 0x64,KEY_F(27), 0x65,KEY_F(28), 0x66,KEY_F(29), 0x67,KEY_F(30),
- X 0x73,KEY_LEFT, 0x74,KEY_RIGHT, 0x75,KEY_LL, 0x76,KEY_NPAGE,
- X 0x77,KEY_HOME, 0x84,KEY_PPAGE, 0x100, -1
- X };
- X
- X/****************************************************************/
- X/* Wgetch(win) gets a character from the terminal, in normal, */
- X/* cbreak or raw mode, optionally echoing to window 'win'. */
- X/****************************************************************/
- X
- Xint wgetch(win)
- X WINDOW *win;
- X {
- X short key;
- X short cbr;
- X
- X if (ungind) /* if ungotten char exists */
- X return(ungch[--ungind]); /* remove and return it */
- X
- X if ((!_cursvar.raw) && (!_cursvar.cbreak)) /* if normal */
- X if (gindex < pindex) /* and data in buffer */
- X return(buffer[gindex++]);
- X
- X w = win; /* static for speed & stack */
- X pindex = 0; /* prepare to buffer data */
- X gindex = 0;
- X while(1) /* loop for any buffering */
- X {
- X if (_cursvar.raw) /* get a raw character */
- X key = rawgetch();
- X else /* get a system character */
- X {
- X cbr = _cursesgcb(); /* get ^BREAK status */
- X _cursesscb(_cursvar.orgcbr); /* if break return proper */
- X key = sysgetch();
- X _cursesscb(cbr); /* restore as it was */
- X }
- X if (w->_nodelay && (key == -1)) /* if nodelay and no char */
- X return(-1);
- X if ((key == '\r') && _cursvar.autocr && !_cursvar.raw) /* translate cr */
- X key = '\n';
- X if (_cursvar.echo && (key < 0x100)) /* check if echo */
- X {
- X waddch(w,key);
- X wrefresh(w);
- X }
- X if (_cursvar.raw || _cursvar.cbreak) /* if no buffering */
- X return(key);
- X if (pindex < _INBUFSIZ-2) /* if no overflow, */
- X buffer[pindex++] = key; /* put data in buffer */
- X if ((key == '\n') || (key == '\r')) /* if we got a line */
- X return(buffer[gindex++]);
- X } /* while */
- X return (ERR); /* Can't happen */
- X } /* wgetch */
- X
- X/****************************************************************/
- X/* Flushinp() kills any pending input characters. */
- X/****************************************************************/
- X
- Xvoid flushinp()
- X {
- X while(_curseskeytst()) /* empty keyboard buffer */
- X _curseskey();
- X while(kbhit()) /* empty system's buffers */
- X (void) getch();
- X gindex = 1; /* set indices to kill buffer */
- X pindex = 0;
- X ungind = 0; /* clear ungch array */
- X } /* flushinp */
- X
- X/****************************************************************/
- X/* Wungetch() pushes back it's argument on the input stream. If */
- X/* OK, returns 1, otherwise returns 0. */
- X/****************************************************************/
- X
- Xint wungetch(ch)
- X int ch;
- X {
- X if (ungind >= NUNGETCH) /* pushback stack full */
- X return(0);
- X ungch[ungind++] = ch;
- X return(1);
- X } /* wungetch() */
- X
- X/****************************************************************/
- X/* Mvgetch() first moves the stdscr cursor to a new location, */
- X/* then does a wgetch() on stdscr. */
- X/****************************************************************/
- X
- Xint mvgetch(y,x)
- X int y;
- X int x;
- X {
- X wmove(stdscr,y,x);
- X return(wgetch(stdscr));
- X } /* mvgetch */
- X
- X/****************************************************************/
- X/* Mvwgetch() first moves the cursor of window 'win' to a new */
- X/* location, then does a wgetch() in 'win'. */
- X/****************************************************************/
- X
- Xint mvwgetch(win,y,x)
- X WINDOW *win;
- X int y;
- X int x;
- X {
- X wmove(win,y,x);
- X return(wgetch(win));
- X } /* mvwgetch */
- X
- X/****************************************************************/
- X/* rawgetch() gets a character without any interpretation at */
- X/* all and returns it. If keypad mode is active for the desig- */
- X/* nated window, function key translation will be performed. */
- X/* Otherwise, function keys are ignored.If nodelay mode is */
- X/* active in the window, then rawgetch() returns -1 if no cha- */
- X/* racter is available. */
- X/****************************************************************/
- X
- Xstatic short rawgetch()
- X {
- X short c;
- X
- X if (w->_nodelay && !_curseskeytst())
- X return(-1);
- X while(1) /* loop to get valid char */
- X {
- X if ((c = validchar(_curseskey())) >= 0)
- X return(c);
- X } /* while */
- X return (ERR); /* Can't happen */
- X } /* rawgetch */
- X
- X/****************************************************************/
- X/* Sysgetch() gets a character with normal ^S, ^Q, ^P and ^C */
- X/* interpretation and returns it. If keypad mode is active for */
- X/* the designated window, function key translation will be per- */
- X/* formed. Otherwise, function keys are ignored. If nodelay */
- X/* mode is active in the window, then sysgetch() returns -1 if */
- X/* no character is available. */
- X/****************************************************************/
- X
- Xstatic short sysgetch()
- X {
- X short c;
- X
- X if (w->_nodelay && !kbhit())
- X return(-1);
- X while(1)
- X {
- X c = getch();
- X if (c) /* if not a function key */
- X return(c & 0xff); /* avoids sign-extending */
- X c = getch();
- X if ((c = validchar(c << 8)) >= 0) /* get & check next char */
- X return(c);
- X } /* while */
- X return (ERR); /* Can't happen */
- X } /* sysgetch */
- X
- X/****************************************************************/
- X/* Validchar(c) chacks that 'c' is a valid character, and */
- X/* if so returns it, with function key translation applied if */
- X/* 'w' has keypad mode set. If char is invalid, returns -1. */
- X/****************************************************************/
- X
- Xstatic short validchar(c)
- X int c;
- X {
- X short *scanp;
- X
- X if (c == 0x0300) /* special case, ^@ = NULL */
- X return(0);
- X if (!(c & 0xff00)) /* normal character */
- X return(c);
- X if (!(w->_keypad)) /* skip f keys if not keypad mode */
- X return(-1);
- X c = (c >> 8) & 0xff;
- X scanp = kptab;
- X while(*scanp <= c) /* search for value */
- X { /* (stops on table entry 0x100) */
- X if (*scanp++ == c)
- X return(*scanp); /* found, return it */
- X scanp++;
- X }
- X return(-1); /* not found, invalid */
- X } /* validchar */
- X
- X/****************************************************************/
- X/* _cursespendch() returns 1 if there is any character avai- */
- X/* lable, and 0 if there is none. This is not for programmer */
- X/* usage, but for the updatew routines. */
- X/****************************************************************/
- X
- Xbool _cursespendch()
- X {
- X if (ungind) /* ungotten char */
- X return(TRUE);
- X if (pindex > gindex) /* buffered char */
- X return(TRUE);
- X if (_cursvar.raw) /* raw mode test */
- X return(_curseskeytst());
- X return((bool)kbhit()); /* normal mode test */
- X } /* _cursespendch */
- END_OF_charget.c
- if test 9326 -ne `wc -c <charget.c`; then
- echo \"charget.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f cursesio.asm -a "${1}" != "-c" ; then
- echo Will not over-write existing file \"cursesio.asm\"
- else
- echo Extracting - \"cursesio.asm\"
- sed "s/^X//" >cursesio.asm <<'END_OF_cursesio.asm'
- X TITLE PCcurses BIOS Control Functions for MicroSoft Assembler
- X NAME CURSESIO
- X PAGE 46,132
- X ;****************************************************************
- X ;* CURSESIO.ASM *
- X ;* *
- X ;* This file contains 'C' functions for the MicroSoft 'C' com- *
- X ;* piler v.4.0, and for Borland Turbo 'C'. It exercises a num- *
- X ;* ber of BIOS video calls, and is intended for inclusion in *
- X ;* a curses library package. *
- X ;* *
- X ;* The two files FARNEAR.INC and SMALHUGE.INC each contain one *
- X ;* EQUate. These define the module's memory model. *
- X ;* *
- X ;****************************************************************
- X ;* This version of curses is based on ncurses, a curses version *
- X ;* originally written by Pavel Curtis at Cornell University. *
- X ;* I have made substantial changes to make it run on IBM PC's, *
- X ;* and therefore consider myself free to make it public domain. *
- X ;* Bjorn Larsson (bl@infovox.se) *
- X ;****************************************************************
- X ;* Author: Bjorn Larsson *
- X ;* Revised: *
- X ;* 1.4: For other module changes: 901114 *
- X ;* 1.3: Changes in 'C' modules for checking with *
- X ;* MSC -W3, Turbo'C' -w -w-pro checkes: 881005 *
- X ;* 1.2: Changed call sequence to some routines, thanks *
- X ;* to S. Creps. Changed segment name in far code *
- X ;* mode, thanks to N.D. Pentcheff: 881002 *
- X ;* 1.1: Bad error in curseskeytst(): JZ -> JNZ! 870911 *
- X ;* 1.0: Release: 870515 *
- X ;****************************************************************
- X ;
- X INCLUDE FARNEAR.INC ;DEFINE FAR OR NEAR CALL SEQUENCE
- X INCLUDE SMALHUGE.INC ;DEFINE FAR OR NEAR DATA ACCESS
- X ;
- XSYSTEM EQU 21H ;SYSTEM CALL
- XBRKCHK EQU 33H ;BREAK SET/CHECK FUNCTION CODE
- X ;
- X if far_call ;OTHER TEXT NAME IF FAR CALLS
- XCURSESIO_TEXT SEGMENT BYTE PUBLIC 'CODE'
- X ASSUME CS: CURSESIO_TEXT
- X else
- X_TEXT SEGMENT BYTE PUBLIC 'CODE'
- X ASSUME CS: _TEXT
- X endif
- X ;
- X ;****************************************************************
- X ;* Function entry and exit macros, and parameter fetch macro. *
- X ;* Used by all functions. *
- X ;****************************************************************
- X ;
- Xc_entry MACRO f_name
- X ;
- X if far_call
- X&f_name proc far
- X else
- X&f_name proc near
- X endif
- X push bp
- X mov bp,sp
- X push di
- X push si
- X ;
- X ENDM
- X ;
- Xc_exit MACRO f_name
- X ;
- X pop si
- X pop di
- X pop bp
- X ret
- X&f_name endp
- X ;
- X ENDM
- X ;
- Xg_parm MACRO reg,p_num
- X if far_call
- X mov ®,[bp+&p_num*2+4]
- X else
- X mov ®,[bp+&p_num*2+2]
- X endif
- X ;
- X ENDM
- X ;
- X DB '@(#)cursesio.asm v.1.4 - 900114', 0
- X ;
- X PAGE
- X ;****************************************************************
- X ;* _cursescattr *
- X ;* *
- X ;* void _cursescattr(chr,attr) *
- X ;* *
- X ;* Writes char 'chr' with attributes 'attr' to the current cur- *
- X ;* sor location. *
- X ;****************************************************************
- X PUBLIC __cursescattr
- X ;
- X c_entry __cursescattr
- X MOV AH,9
- X MOV BH,0 ;USE PAGE 0
- X g_parm AL,1 ;GET CHR PARAMETER
- X g_parm BL,2 ;GET ATTR PARAMETER
- X MOV CX,1 ;PUT 1 CHARACTER
- X INT 10H
- X c_exit __cursescattr
- X ;
- X ;****************************************************************
- X ;* _cursescursor *
- X ;* *
- X ;* void _cursescursor(row,column) *
- X ;* *
- X ;* Sets the cursor position in video page 0. 'row' and 'column' *
- X ;* are the cursor address. If 'row' is set to 25, no cursor at *
- X ;* all is displayed. *
- X ;****************************************************************
- X PUBLIC __cursescursor
- X ;
- X c_entry __cursescursor
- X MOV AH,2
- X MOV BH,0 ;USE PAGE 0
- X g_parm DH,1 ;GET ROW PARAMETER
- X g_parm DL,2 ;GET COLUMN PARAMETER
- X INT 10H
- X c_exit __cursescursor
- X ;
- X ;****************************************************************
- X ;* _cursesgcols *
- X ;* *
- X ;* int _cursesgcols() *
- X ;* *
- X ;* Return the current number of columns on the screen. *
- X ;****************************************************************
- X PUBLIC __cursesgcols
- X ;
- X c_entry __cursesgcols
- X MOV AH,15
- X INT 10H
- X MOV AL,AH
- X XOR AH,AH
- X c_exit __cursesgcols
- X ;
- X ;****************************************************************
- X ;* _cursesputc *
- X ;* *
- X ;* void _cursesputc(chr,colour) *
- X ;* *
- X ;* Output character 'chr' to screen in tty fashion. If a colour *
- X ;* mode is active, the character is written with colour *
- X ;* 'colour'. *
- X ;****************************************************************
- X PUBLIC __cursesputc
- X ;
- X c_entry __cursesputc
- X MOV AH,14
- X g_parm AL,1 ;GET CHR PARAMETER
- X g_parm BL,2 ;GET COLOUR PARAMETER
- X INT 10H
- X c_exit __cursesputc
- X ;
- X ;****************************************************************
- X ;* _cursesscroll *
- X ;* *
- X ;* void _cursesscroll(urow,lcol,lrow,rcol,lines,attr) *
- X ;* *
- X ;* Scroll a window in the current page up or down. Urow, lcol, *
- X ;* lrow,rcol are the window coordinats. lines is the number of *
- X ;* lines to scroll. If 0, clears the window, if < 0 scrolls *
- X ;* down, > 0 scrolls up. Blanks areas that are left, and sets *
- X ;* character attributes to attr. If in a colour graphics mode, *
- X ;* fills them with the colour 'attr' instead. *
- X ;****************************************************************
- X PUBLIC __cursesscroll
- X ;
- X c_entry __cursesscroll
- X g_parm AL,5 ;GET LINES PARAMETER
- X MOV AH,6
- X TEST AL,80H
- X JZ SHORT CS_1
- X ;
- X MOV AH,7
- X NEG AL
- X ;
- XCS_1: g_parm CH,1 ;GET UROW PARAMETER
- X g_parm CL,2 ;GET LCOL PARAMETER
- X g_parm DH,3 ;GET LROW PARAMETER
- X g_parm DL,4 ;GET RCOL PARAMETER
- X g_parm BH,6 ;GET ATTR PARAMETER
- X INT 10H
- X c_exit __cursesscroll
- X ;
- X ;****************************************************************
- X ;* _cursesgcmode *
- X ;* *
- X ;* int _cursesgcmode() *
- X ;* *
- X ;* Return the current cursor type. Bits 8-15 of the return *
- X ;* value is the start scan row, and bits 0-7 is the end scan *
- X ;* row. *
- X ;****************************************************************
- X PUBLIC __cursesgcmode
- X ;
- X c_entry __cursesgcmode
- X MOV AH,3
- X INT 10H
- X MOV AX,CX
- X c_exit __cursesgcmode
- X ;
- X ;****************************************************************
- X ;* _cursescmode *
- X ;* *
- X ;* void _cursescmode(startrow,endrow) *
- X ;* *
- X ;* Sets the cursor type to begin in scan line startrow and end *
- X ;* in scan line endrow. Both values should be 0-31. *
- X ;****************************************************************
- X PUBLIC __cursescmode
- X ;
- X c_entry __cursescmode
- X MOV AH,1
- X g_parm CH,1 ;GET STARTROW PARAMETER
- X g_parm CL,2 ;GET ENDROW PARAMETER
- X INT 10H
- X c_exit __cursescmode
- X ;
- X ;****************************************************************
- X ;* _curseskey *
- X ;* *
- X ;* int _curseskey() *
- X ;* *
- X ;* Returns the next key code struck at the keyboard. If the low *
- X ;* 8 bits are 0, the upper bits contain the extended character *
- X ;* code. If bit 0-7 are non-zero, the upper bits = 0. *
- X ;****************************************************************
- X PUBLIC __curseskey
- X ;
- X c_entry __curseskey
- X MOV AH,0
- X INT 16H
- X CMP AL,0
- X JZ SHORT EXTKEY
- X AND AX,0FFH
- XEXTKEY:
- X c_exit __curseskey
- X ;
- X ;****************************************************************
- X ;* _curseskeytst *
- X ;* *
- X ;* int _curseskeytst() *
- X ;* *
- X ;* Returns 1 if a character is available, 0 otherwise. *
- X ;****************************************************************
- X PUBLIC __curseskeytst
- X ;
- X c_entry __curseskeytst
- X MOV AH,1
- X INT 16H
- X JNZ SHORT TST1
- X MOV AX,0
- X JMP SHORT EXTTST
- XTST1: MOV AX,1
- XEXTTST:
- X c_exit __curseskeytst
- X ;
- X ;****************************************************************
- X ;* _cursesgcb *
- X ;* *
- X ;* int _cursesgcb() *
- X ;* *
- X ;* Returns 1 if MSDOS BREAK CHECK is on, otherwise 0. *
- X ;****************************************************************
- X PUBLIC __cursesgcb
- X ;
- X c_entry __cursesgcb
- X MOV AX,BRKCHK*256+0
- X INT SYSTEM
- X XOR AH,AH
- X MOV AL,DL
- X c_exit __cursesgcb
- X ;
- X ;****************************************************************
- X ;* _cursesscb *
- X ;* *
- X ;* void _cursesscb(setting) *
- X ;* *
- X ;* Sets MSDOS BREAK CHECK according to 'setting'. *
- X ;****************************************************************
- X PUBLIC __cursesscb
- X ;
- X c_entry __cursesscb
- X MOV AX,BRKCHK*256+1
- X g_parm DL,1
- X AND DL,DL
- X JZ SHORT SCB1
- X MOV DL,1
- XSCB1: INT SYSTEM
- X c_exit __cursesscb
- X ;
- X if far_call
- XCURSESIO_TEXT ENDS
- X else
- X_TEXT ENDS
- X endif
- X if1
- X %OUT Pass 1 Completed
- X else
- X %OUT Assembly Completed
- X endif
- X END
- END_OF_cursesio.asm
- if test 8421 -ne `wc -c <cursesio.asm`; then
- echo \"cursesio.asm\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f makefile.68 -a "${1}" != "-c" ; then
- echo Will not over-write existing file \"makefile.68\"
- else
- echo Extracting - \"makefile.68\"
- sed "s/^X//" >makefile.68 <<'END_OF_makefile.68'
- X#################################################################
- X# PCCURSES #
- X# #
- X# Makefile for the 68K version of the PCCURSES runtime #
- X# library (CURSES.LIB) for the Paragon 'C' compiler and #
- X# assembler. #
- X#################################################################
- X# 1.4: Release: 900114 #
- X#################################################################
- X
- XINCDIR=\mcc68k
- XLIBDIR=\m68k\lib
- XWRKDIR=wrk
- XCC=mcc68k
- XCFLAGS= /opt=all /DEFINE=BUG68K=1
- XASM=asm68k
- XAFLAGS= /E
- XLINK=lod68k
- XLFLAGS= /T /X
- XLIB=lib68k
- X
- X
- XHEADERS= $(INCDIR) $(INCDIR)\curses.h \
- X $(INCDIR)\curspriv.h $(INCDIR)\stdio.h \
- X $(INCDIR)\conio.h
- X
- XOBJS= $(WRKDIR) \
- X $(WRKDIR)\attrib.obj $(WRKDIR)\beep.obj \
- X $(WRKDIR)\border.obj $(WRKDIR)\boxes.obj \
- X $(WRKDIR)\charadd.obj $(WRKDIR)\chardel.obj \
- X $(WRKDIR)\charget.obj $(WRKDIR)\charins.obj \
- X $(WRKDIR)\charpick.obj $(WRKDIR)\clrtobot.obj \
- X $(WRKDIR)\clrtoeol.obj $(WRKDIR)\endwin.obj \
- X $(WRKDIR)\initscr.obj $(WRKDIR)\linedel.obj \
- X $(WRKDIR)\lineins.obj $(WRKDIR)\longname.obj \
- X $(WRKDIR)\move.obj $(WRKDIR)\mvcursor.obj \
- X $(WRKDIR)\newwin.obj $(WRKDIR)\options.obj \
- X $(WRKDIR)\overlay.obj $(WRKDIR)\prntscan.obj \
- X $(WRKDIR)\refresh.obj $(WRKDIR)\scrreg.obj \
- X $(WRKDIR)\setmode.obj $(WRKDIR)\setterm.obj \
- X $(WRKDIR)\stradd.obj $(WRKDIR)\strget.obj \
- X $(WRKDIR)\tabsize.obj $(WRKDIR)\termmisc.obj \
- X $(WRKDIR)\unctrl.obj $(WRKDIR)\update.obj \
- X $(WRKDIR)\winclear.obj $(WRKDIR)\windel.obj \
- X $(WRKDIR)\winerase.obj $(WRKDIR)\winmove.obj \
- X $(WRKDIR)\winscrol.obj $(WRKDIR)\wintouch.obj \
- X $(WRKDIR)\curses68.obj
- X
- X#################################################################
- X# Default targets. #
- X#################################################################
- X
- Xdefault: $(HEADERS) $(LIBDIR)\curses.lib
- X
- X#################################################################
- X# Directory creation and include file installation #
- X#################################################################
- X
- X$(LIBDIR):
- X mkdir $(LIBDIR)
- X
- X$(WRKDIR):
- X mkdir $(WRKDIR)
- X
- X$(INCDIR):
- X mkdir $(INCDIR)
- X
- X$(INCDIR)\curses.h: curses.h
- X attrib -r $(INCDIR)\curses.h
- X copy curses.h $(INCDIR)\curses.h
- X attrib +r $(INCDIR)\curses.h
- X
- X$(INCDIR)\curspriv.h: curspriv.h
- X attrib -r $(INCDIR)\curspriv.h
- X copy curspriv.h $(INCDIR)
- X attrib +r $(INCDIR)\curspriv.h
- X
- X$(INCDIR)\stdio.h: ..\rts68\stdio.h
- X attrib -r $(INCDIR)\stdio.h
- X copy ..\rts68\stdio.h $(INCDIR)
- X attrib +r $(INCDIR)\stdio.h
- X
- X$(INCDIR)\conio.h: ..\rts68\conio.h
- X attrib -r $(INCDIR)\conio.h
- X copy ..\rts68\conio.h $(INCDIR)
- X attrib +r $(INCDIR)\conio.h
- X
- X#################################################################
- X# Resultant linkable files generation: #
- X#################################################################
- X
- X$(LIBDIR)\curses.lib: $(LIBDIR) $(OBJS)
- X cd $(WRKDIR)
- X command -c $(LIB) <..\curses68.cmd
- X copy curses.lib $(LIBDIR)
- X cd ..
- X
- X#################################################################
- X# Object file generation: #
- X#################################################################
- X
- X$(WRKDIR)\attrib.obj: attrib.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=attrib.asm ..\attrib.c
- X command -c break on
- X $(ASM) attrib.asm,attrib.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\beep.obj: beep.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=beep.asm ..\beep.c
- X command -c break on
- X $(ASM) beep.asm,beep.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\border.obj: border.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=border.asm ..\border.c
- X command -c break on
- X $(ASM) border.asm,border.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\boxes.obj: boxes.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=boxes.asm ..\boxes.c
- X command -c break on
- X $(ASM) boxes.asm,boxes.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\charadd.obj: charadd.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=charadd.asm ..\charadd.c
- X command -c break on
- X $(ASM) charadd.asm,charadd.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\chardel.obj: chardel.c $(HEADERS)
- X cd $(WRKDIR)
- X $(CC) $(CFLAGS) /output=chardel.asm ..\chardel.c
- X command -c break on
- X $(ASM) chardel.asm,chardel.obj,nul $(AFLAGS)
- X command -c break on
- X cd ..
- X
- X$(WRKDIR)\charget.obj: charget.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=charget.asm ..\charget.c
- X command -c break on
- X $(ASM) charget.asm,charget.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\charins.obj: charins.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=charins.asm ..\charins.c
- X command -c break on
- X $(ASM) charins.asm,charins.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\charpick.obj: charpick.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=charpick.asm ..\charpick.c
- X command -c break on
- X $(ASM) charpick.asm,charpick.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\clrtobot.obj: clrtobot.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=clrtobot.asm ..\clrtobot.c
- X command -c break on
- X $(ASM) clrtobot.asm,clrtobot.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\clrtoeol.obj: clrtoeol.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=clrtoeol.asm ..\clrtoeol.c
- X command -c break on
- X $(ASM) clrtoeol.asm,clrtoeol.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\endwin.obj: endwin.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=endwin.asm ..\endwin.c
- X command -c break on
- X $(ASM) endwin.asm,endwin.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\initscr.obj: initscr.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=initscr.asm ..\initscr.c
- X command -c break on
- X $(ASM) initscr.asm,initscr.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\linedel.obj: linedel.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=linedel.asm ..\linedel.c
- X command -c break on
- X $(ASM) linedel.asm,linedel.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\lineins.obj: lineins.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=lineins.asm ..\lineins.c
- X command -c break on
- X $(ASM) lineins.asm,lineins.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\longname.obj: longname.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=longname.asm ..\longname.c
- X command -c break on
- X $(ASM) longname.asm,longname.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\move.obj: move.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=move.asm ..\move.c
- X command -c break on
- X $(ASM) move.asm,move.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\mvcursor.obj: mvcursor.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=mvcursor.asm ..\mvcursor.c
- X command -c break on
- X $(ASM) mvcursor.asm,mvcursor.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\newwin.obj: newwin.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=newwin.asm ..\newwin.c
- X command -c break on
- X $(ASM) newwin.asm,newwin.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\options.obj: options.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=options.asm ..\options.c
- X command -c break on
- X $(ASM) options.asm,options.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\overlay.obj: overlay.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=overlay.asm ..\overlay.c
- X command -c break on
- X $(ASM) overlay.asm,overlay.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\prntscan.obj: prntscan.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=prntscan.asm ..\prntscan.c
- X command -c break on
- X $(ASM) prntscan.asm,prntscan.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\refresh.obj: refresh.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=refresh.asm ..\refresh.c
- X command -c break on
- X $(ASM) refresh.asm,refresh.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\scrreg.obj: scrreg.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=scrreg.asm ..\scrreg.c
- X command -c break on
- X $(ASM) scrreg.asm,scrreg.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\setmode.obj: setmode.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=setmode.asm ..\setmode.c
- X command -c break on
- X $(ASM) setmode.asm,setmode.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\setterm.obj: setterm.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=setterm.asm ..\setterm.c
- X command -c break on
- X $(ASM) setterm.asm,setterm.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\stradd.obj: stradd.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=stradd.asm ..\stradd.c
- X command -c break on
- X $(ASM) stradd.asm,stradd.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\strget.obj: strget.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=strget.asm ..\strget.c
- X command -c break on
- X $(ASM) strget.asm,strget.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\tabsize.obj: tabsize.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=tabsize.asm ..\tabsize.c
- X command -c break on
- X $(ASM) tabsize.asm,tabsize.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\termmisc.obj: termmisc.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=termmisc.asm ..\termmisc.c
- X command -c break on
- X $(ASM) termmisc.asm,termmisc.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\unctrl.obj: unctrl.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=unctrl.asm ..\unctrl.c
- X command -c break on
- X $(ASM) unctrl.asm,unctrl.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\update.obj: update.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=update.asm ..\update.c
- X command -c break on
- X $(ASM) update.asm,update.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\winclear.obj: winclear.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=winclear.asm ..\winclear.c
- X command -c break on
- X $(ASM) winclear.asm,winclear.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\windel.obj: windel.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=windel.asm ..\windel.c
- X command -c break on
- X $(ASM) windel.asm,windel.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\winerase.obj: winerase.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=winerase.asm ..\winerase.c
- X command -c break on
- X $(ASM) winerase.asm,winerase.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\winmove.obj: winmove.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=winmove.asm ..\winmove.c
- X command -c break on
- X $(ASM) winmove.asm,winmove.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\winscrol.obj: winscrol.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=winscrol.asm ..\winscrol.c
- X command -c break on
- X $(ASM) winscrol.asm,winscrol.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\wintouch.obj: wintouch.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=wintouch.asm ..\wintouch.c
- X command -c break on
- X $(ASM) wintouch.asm,wintouch.obj,nul $(AFLAGS)
- X cd ..
- X
- X$(WRKDIR)\curses68.obj: curses68.c $(HEADERS)
- X cd $(WRKDIR)
- X command -c break on
- X $(CC) $(CFLAGS) /output=curses68.asm ..\curses68.c
- X command -c break on
- X $(ASM) curses68.asm,curses68.obj,nul $(AFLAGS)
- X cd ..
- X
- X#################################################################
- X# Maintenance chores #
- X#################################################################
- X
- Xclean:
- X rm -il $(WRKDIR)\*.*
- X rmdir $(WRKDIR)
- X
- Xshar:
- X command -c makekit -x *.* >manifest
- X makekit -m *.*
- X del manifest.*
- END_OF_makefile.68
- if test 11256 -ne `wc -c <makefile.68`; then
- echo \"makefile.68\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f prntscan.c -a "${1}" != "-c" ; then
- echo Will not over-write existing file \"prntscan.c\"
- else
- echo Extracting - \"prntscan.c\"
- sed "s/^X//" >prntscan.c <<'END_OF_prntscan.c'
- X/****************************************************************/
- X/* Printw() and scanw() routines of the PCcurses package */
- X/* */
- X/****************************************************************/
- X/* This version of curses is based on ncurses, a curses version */
- X/* originally written by Pavel Curtis at Cornell University. */
- X/* I have made substantial changes to make it run on IBM PC's, */
- X/* and therefore consider myself free to make it public domain. */
- X/* Bjorn Larsson (bl@infovox.se) */
- X/****************************************************************/
- X/* IMPLEMENTATION NOTE 1 */
- X/* These routines make a local copy of their parameter stack, */
- X/* assuming at most 5 'double' arguments were passed (== 40 */
- X/* bytes == 20 int's == 10 long's == 10-20 pointers {depending */
- X/* on memory model}, etc). This means the invokation of the */
- X/* routines themself require at least 80 bytes of stack just */
- X/* for the parameters, and the sprintf() and sscanf() functions */
- X/* will require more. Therefore, this module should be compiled */
- X/* with stack checking on to avoid stack overflow errors. */
- X/****************************************************************/
- X/* IMPLEMENTATION NOTE 2 */
- X/* This curses version is also used in a special environment */
- X/* with a 68000 CPU. The 68K compiler used has a bug in the */
- X/* standard library, which means that sprintf will not print */
- X/* newlines right. Therefore a workaround has been included in */
- X/* this file, conditionalized by '#if BUG68K'. This does not */
- X/* affect the PC version in any way, except the source is a */
- X/* little more obscure... */
- X/****************************************************************/
- X/* 1.4: Use of short wherever possible. Portability */
- X/* improvements. 68K bug workaround: 900114 */
- X/* 1.3: MSC -W3, Turbo'C' -w -w-pro checkes: 881005 */
- X/* 1.2: Rcsid[] string for maintenance: 881002 */
- X/* 1.0: Release: 870515 */
- X/****************************************************************/
- X
- X#include <curses.h>
- X#include <curspriv.h>
- X
- Xchar _curses_prntscan_rcsid[] = "@(#)prntscan.c v.1.4 - 900114";
- X
- Xstatic int pblen(); /* gets length of buffer */
- X
- X#if BUG68K
- Xstatic void setnl(); /* conv nl -> CTRL-\ */
- Xstatic void getnl(); /* conv CTRL-\ -> nl */
- X#endif
- X
- Xstatic char printscanbuf[513]; /* buffer used during I/O */
- X
- X/****************************************************************/
- X/* Wprintw(win,fmt,args) does a printf() in window 'win'. */
- X/****************************************************************/
- X
- Xint wprintw(win,fmt,A1,A2,A3,A4,A5)
- X WINDOW *win;
- X char *fmt;
- X double A1,A2,A3,A4,A5;
- X {
- X#if BUG68K
- X setnl(fmt);
- X sprintf(printscanbuf,fmt,A1,A2,A3,A4,A5);
- X getnl(fmt);
- X getnl(printscanbuf);
- X#else
- X sprintf(printscanbuf,fmt,A1,A2,A3,A4,A5);
- X#endif
- X if (waddstr(win,printscanbuf) == ERR)
- X return(ERR);
- X return(pblen());
- X } /* wprintw */
- X
- X/****************************************************************/
- X/* Printw(fmt,args) does a printf() in stdscr. */
- X/****************************************************************/
- X
- Xint printw(fmt,A1,A2,A3,A4,A5)
- X char *fmt;
- X double A1,A2,A3,A4,A5;
- X {
- X#if BUG68K
- X setnl(fmt);
- X sprintf(printscanbuf,fmt,A1,A2,A3,A4,A5);
- X getnl(fmt);
- X getnl(printscanbuf);
- X#else
- X sprintf(printscanbuf,fmt,A1,A2,A3,A4,A5);
- X#endif
- X if(waddstr(stdscr,printscanbuf) == ERR)
- X return(ERR);
- X return(pblen());
- X } /* printw */
- X
- X/****************************************************************/
- X/* Mvprintw(fmt,args) moves the stdscr cursor to a new posi- */
- X/* tion, then does a printf() in stdscr. */
- X/****************************************************************/
- X
- Xint mvprintw(y,x,fmt,A1,A2,A3,A4,A5)
- X int y;
- X int x;
- X char *fmt;
- X double A1,A2,A3,A4,A5;
- X {
- X if (wmove(stdscr,y,x) == ERR)
- X return(ERR);
- X#if BUG68K
- X setnl(fmt);
- X sprintf(printscanbuf,fmt,A1,A2,A3,A4,A5);
- X getnl(fmt);
- X getnl(printscanbuf);
- X#else
- X sprintf(printscanbuf,fmt,A1,A2,A3,A4,A5);
- X#endif
- X if(waddstr(stdscr,printscanbuf) == ERR)
- X return(ERR);
- X return(pblen());
- X } /* mvprintw */
- X
- X/****************************************************************/
- X/* Mvwprintw(win,fmt,args) moves the window 'win's cursor to */
- X/* a new position, then does a printf() in window 'win'. */
- X/****************************************************************/
- X
- Xint mvwprintw(win,y,x,fmt,A1,A2,A3,A4,A5)
- X WINDOW *win;
- X int y;
- X int x;
- X char *fmt;
- X double A1,A2,A3,A4,A5;
- X {
- X if (wmove(win,y,x) == ERR)
- X return(ERR);
- X#if BUG68K
- X setnl(fmt);
- X sprintf(printscanbuf,fmt,A1,A2,A3,A4,A5);
- X getnl(fmt);
- X getnl(printscanbuf);
- X#else
- X sprintf(printscanbuf,fmt,A1,A2,A3,A4,A5);
- X#endif
- X if(waddstr(win,printscanbuf) == ERR)
- X return(ERR);
- X return(pblen());
- X } /* mvwprintw */
- X
- X/****************************************************************/
- X/* Wscanw(win,fmt,args) gets a string via window 'win', then */
- X/* scans the string using format 'fmt' to extract the values */
- X/* and put them in the variables pointed to the arguments. */
- X/****************************************************************/
- X
- Xint wscanw(win,fmt,A1,A2,A3,A4,A5)
- X WINDOW *win;
- X char *fmt;
- X double A1,A2,A3,A4,A5; /* really pointers */
- X {
- X wrefresh(win); /* set cursor */
- X if (wgetstr(win,printscanbuf) == ERR) /* get string */
- X return(ERR);
- X return(sscanf(printscanbuf,fmt,A1,A2,A3,A4,A5));
- X } /* wscanw */
- X
- X/****************************************************************/
- X/* Scanw(fmt,args) gets a string via stdscr, then scans the */
- X/* string using format 'fmt' to extract the values and put them */
- X/* in the variables pointed to the arguments. */
- X/****************************************************************/
- X
- Xint scanw(fmt,A1,A2,A3,A4,A5)
- X char *fmt;
- X double A1,A2,A3,A4,A5; /* really pointers */
- X {
- X wrefresh(stdscr); /* set cursor */
- X if (wgetstr(stdscr,printscanbuf) == ERR) /* get string */
- X return(ERR);
- X return(sscanf(printscanbuf,fmt,A1,A2,A3,A4,A5));
- X } /* scanw */
- X
- X/****************************************************************/
- X/* Mvscanw(y,x,fmt,args) moves stdscr's cursor to a new posi- */
- X/* tion, then gets a string via stdscr and scans the string */
- X/* using format 'fmt' to extract the values and put them in the */
- X/* variables pointed to the arguments. */
- X/****************************************************************/
- X
- Xint mvscanw(y,x,fmt,A1,A2,A3,A4,A5)
- X int y;
- X int x;
- X char *fmt;
- X double A1,A2,A3,A4,A5; /* really pointers */
- X {
- X if (wmove(stdscr,y,x) == ERR)
- X return(ERR);
- X wrefresh(stdscr); /* set cursor */
- X if (wgetstr(stdscr,printscanbuf) == ERR) /* get string */
- X return(ERR);
- X return(sscanf(printscanbuf,fmt,A1,A2,A3,A4,A5));
- X } /* mvscanw */
- X
- X/****************************************************************/
- X/* Mvwscanw(win,y,x,fmt,args) moves window 'win's cursor to a */
- X/* new position, then gets a string via 'win' and scans the */
- X/* string using format 'fmt' to extract the values and put them */
- X/* in the variables pointed to the arguments. */
- X/****************************************************************/
- X
- Xint mvwscanw(win,y,x,fmt,A1,A2,A3,A4,A5)
- X WINDOW *win;
- X int y;
- X int x;
- X char *fmt;
- X double A1,A2,A3,A4,A5; /* really pointers */
- X {
- X if (wmove(win,y,x) == ERR)
- X return(ERR);
- X wrefresh(win); /* set cursor */
- X if (wgetstr(win,printscanbuf) == ERR) /* get string */
- X return(ERR);
- X return(sscanf(printscanbuf,fmt,A1,A2,A3,A4,A5));
- X } /* mvwscanw */
- X
- X/****************************************************************/
- X/* Pblen() returns the length of the string in printscanbuf. */
- X/****************************************************************/
- X
- Xstatic int pblen()
- X {
- X char *p = printscanbuf;
- X
- X while(*p++);
- X return((int) (p - printscanbuf - 1));
- X } /* plben */
- X
- X#if BUG68K
- X/****************************************************************/
- X/* This function circumvents a problem in the 68000 C library: */
- X/* If the standard sprintf is used, it will ignore any newlines */
- X/* in the format string. Therefore this routine changes the */
- X/* newlines to CTRL-\ characters, to be restored later by the */
- X/* getnl() function. */
- X/****************************************************************/
- X
- Xstatic void setnl(fmt)
- X char *fmt;
- X {
- X while (*fmt)
- X {
- X if (*fmt == '\n')
- X *fmt = 0x1c;
- X fmt++;
- X } /* while */
- X } /* setnl */
- X
- X/****************************************************************/
- X/* This function circumvents a problem in the 68000 C library: */
- X/* If the standard sprintf is used, it will ignore any newlines */
- X/* in the format string. Therefore this routine changes CTRL-\ */
- X/* characters (already set by setnl()) back to newlines. */
- X/****************************************************************/
- X
- Xstatic void getnl(fmt)
- X char *fmt;
- X {
- X while (*fmt)
- X {
- X if (*fmt == 0x1c)
- X *fmt = '\n';
- X fmt++;
- X } /* while */
- X } /* getnl */
- X#endif
- END_OF_prntscan.c
- if test 8950 -ne `wc -c <prntscan.c`; then
- echo \"prntscan.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f update.c -a "${1}" != "-c" ; then
- echo Will not over-write existing file \"update.c\"
- else
- echo Extracting - \"update.c\"
- sed "s/^X//" >update.c <<'END_OF_update.c'
- X/****************************************************************/
- X/* Doupdate() routine of the PCcurses package */
- X/* */
- X/****************************************************************/
- X/* This version of curses is based on ncurses, a curses version */
- X/* originally written by Pavel Curtis at Cornell University. */
- X/* I have made substantial changes to make it run on IBM PC's, */
- X/* and therefore consider myself free to make it public domain. */
- X/* Bjorn Larsson (bl@infovox.se) */
- X/****************************************************************/
- X/* 1.4: Use of short wherever possible. Portability */
- X/* improvements. Superflous parameter in */
- X/* cursescattr() removed. Clearscreen() changed */
- X/* so curses is guaranteed to know where the psy- */
- X/* sical cursor is at all times: 900114 */
- X/* 1.3: MSC -W3, Turbo'C' -w -w-pro checkes: 881005 */
- X/* 1.2: Changed call sequence to cursesio.[c,asm], Thanks */
- X/* to S. Creps. Rcsid[] string for maintenance: 881002 */
- X/* 1.0: Release: 870515 */
- X/****************************************************************/
- X
- X#include <curses.h>
- X#include <curspriv.h>
- X
- Xstatic void clrupdate(); /* fwd declaration */
- Xstatic bool transformline();
- Xstatic void clearscreen();
- Xstatic void gotoxy();
- Xstatic void Putchar();
- X
- Xchar _curses_update_rcsid[] = "@(#)update.c v.1.4 - 900114";
- X
- Xstatic WINDOW *twin; /* used by many routines */
- X
- Xstatic char atrtab[64] = /* attribute encoding table. */
- X { /* feel free to edit if your */
- X (char)7, /* NORMAL (0) */ /* display board supports all */
- X (char)0x87, /* BLINK */ /* possible combinations */
- X (char)0, /* BLANK */
- X (char)0, /* BLINK & BLANK */
- X (char)0xf, /* BOLD */
- X (char)0x8f, /* BOLD & BLINK */
- X (char)0, /* BOLD & BLANK */
- X (char)0, /* BOLD & BLINK & BLANK */
- X (char)0x70, /* REVERSE (8) */
- X (char)0xf0, /* REVERSE & BLINK */
- X (char)0, /* REVERSE & BLANK */
- X (char)0, /* REVERSE & BLINK & BLANK */
- X (char)0x78, /* REVERSE & BOLD */
- X (char)0xf8, /* REVERSE & BOLD & BLINK */
- X (char)0, /* REVERSE & BOLD & BLANK */
- X (char)0, /* REVERSE & BOLD & BLINK & BLANK */
- X (char)0xf, /* STANDOUT (10) */
- X (char)0x8f, /* STANDOUT & BLINK */
- X (char)0, /* STANDOUT & BLANK */
- X (char)0, /* STANDOUT & BLINK & BLANK */
- X (char)0xf, /* STANDOUT & BOLD */
- X (char)0x8f, /* STANDOUT & BOLD & BLINK */
- X (char)0, /* STANDOUT & BOLD & BLANK */
- X (char)0, /* STANDOUT & BOLD & BLINK & BLANK */
- X (char)0x70, /* STANDOUT & REVERSE (18) */
- X (char)0xf0, /* STANDOUT & REVERSE & BLINK */
- X (char)0, /* STANDOUT & REVERSE & BLANK */
- X (char)0, /* STANDOUT & REVERSE & BLINK & BLANK */
- X (char)0x70, /* STANDOUT & REVERSE & BOLD */
- X (char)0xf0, /* STANDOUT & REVERSE & BOLD & BLINK */
- X (char)0, /* STANDOUT & REVERSE & BOLD & BLANK */
- X (char)0, /* STANDOUT & REVERSE & BOLD & BLINK & BLANK */
- X (char)1, /* UNDERLINE (20) */
- X (char)0x81, /* UNDERLINE & BLINK */
- X (char)0, /* UNDERLINE & BLANK */
- X (char)0, /* UNDERLINE & BLINK & BLANK */
- X (char)9, /* UNDERLINE & BOLD */
- X (char)0x89, /* UNDERLINE & BOLD & BLINK */
- X (char)0, /* UNDERLINE & BOLD & BLANK */
- X (char)0, /* UNDERLINE & BOLD & BLINK & BLANK */
- X (char)0x70, /* UNDERLINE & REVERSE (28) */
- X (char)0xf0, /* UNDERLINE & REVERSE & BLINK */
- X (char)0, /* UNDERLINE & REVERSE & BLANK */
- X (char)0, /* UNDERLINE & REVERSE & BLINK & BLANK */
- X (char)0x79, /* UNDERLINE & REVERSE & BOLD */
- X (char)0xf9, /* UNDERLINE & REVERSE & BOLD & BLINK */
- X (char)0, /* UNDERLINE & REVERSE & BOLD & BLANK */
- X (char)0, /* UNDERLINE & REVERSE & BOLD & BLINK & BLANK */
- X (char)9, /* UNDERLINE & STANDOUT (30) */
- X (char)0x89, /* UNDERLINE & STANDOUT & BLINK */
- X (char)0, /* UNDERLINE & STANDOUT & BLANK */
- X (char)0, /* UNDERLINE & STANDOUT & BLINK & BLANK */
- X (char)9, /* UNDERLINE & STANDOUT & BOLD */
- X (char)0x89, /* UNDERLINE & STANDOUT & BOLD & BLINK */
- X (char)0, /* UNDERLINE & STANDOUT & BOLD & BLANK */
- X (char)0, /* UNDERLINE & STANDOUT & BOLD & BLINK & BLANK */
- X (char)0x70, /* UNDERLINE & STANDOUT & REVERSE (38) */
- X (char)0xf0, /* UNDERLINE & STANDOUT & REVERSE & BLINK */
- X (char)0, /* UNDERLINE & STANDOUT & REVERSE & BLANK */
- X (char)0, /* UNDERLINE & STANDOUT & REVERSE & BLINK & BLANK */
- X (char)0x70, /* UNDERLINE & STANDOUT & REVERSE & BOLD */
- X (char)0xf0, /* UNDERLINE & STANDOUT & REVERSE & BOLD & BLINK */
- X (char)0, /* UNDERLINE & STANDOUT & REVERSE & BOLD & BLANK */
- X (char)0, /* UNDERLINE & STANDOUT & REVERSE & BOLD & BLINK & BLANK */
- X };
- X
- X/****************************************************************/
- X/* Doupdate() updates the physical screen to look like _curs- */
- X/* var.tmpwin if curscr is not 'Clear-marked'. Otherwise it */
- X/* updates the screen to look like curscr. */
- X/****************************************************************/
- X
- Xvoid doupdate()
- X {
- X short i;
- X
- X twin = _cursvar.tmpwin;
- X if (curscr->_clear)
- X clrupdate(curscr);
- X else
- X {
- X if (twin->_clear)
- X clrupdate(twin);
- X else
- X {
- X for (i=0; i < LINES; i++)
- X if (twin->_minchng[i] != _NO_CHANGE)
- X if (transformline(i))
- X break;
- X } /* else */
- X } /* else */
- X curscr->_curx = twin->_curx;
- X curscr->_cury = twin->_cury;
- X gotoxy(curscr->_cury, curscr->_curx);
- X } /* doupdate */
- X
- X/****************************************************************/
- X/* Clrupdate(scr) updates the screen by clearing it and then */
- X/* redraw it in it's entirety. If _cursvar.refrbrk is TRUE, and */
- X/* there is pending input characters, the update will be pre- */
- X/* maturely terminated. */
- X/****************************************************************/
- X
- Xstatic void clrupdate(scr)
- X WINDOW *scr;
- X {
- X short *src;
- X short *dst;
- X short i;
- X short j;
- X static WINDOW *w;
- X
- X w = curscr;
- X
- X if (scr != w) /* copy scr to curscr */
- X {
- X for (i=0; i < LINES; i++)
- X {
- X src = scr->_line[i];
- X dst = w->_line[i];
- X for (j=0; j < COLS; j++)
- X *dst++ = *src++;
- X } /* for */
- X } /* if */
- X clearscreen(); /* clear physical screen */
- X scr->_clear = FALSE;
- X for (i=0; i < LINES; i++) /* update physical screen */
- X {
- X src = w->_line[i];
- X for(j=0; j < COLS; j++)
- X {
- X if (*src != (' ' | ATR_NRM))
- X {
- X gotoxy(i,j);
- X Putchar(*src);
- X } /* if */
- X src++;
- X } /* for */
- X if(_cursvar.refrbrk && _cursespendch())
- X return;
- X } /* for */
- X } /* clrupdate */
- X
- X/****************************************************************/
- X/* Transformline() updates the given physical line to look */
- X/* like the corresponding line in _cursvar.tmpwin. Transform- */
- X/* line returns 1 if premature refresh end is allowed, and */
- X/* there is an input character pending. */
- X/****************************************************************/
- X
- Xstatic bool transformline(lineno)
- X register int lineno;
- X {
- X short *dstp;
- X short *srcp;
- X short x;
- X short endx;
- X
- X x = twin->_minchng[lineno];
- X endx = twin->_maxchng[lineno];
- X dstp = curscr->_line[lineno] + x;
- X srcp = twin->_line[lineno] + x;
- X
- X for( ; x <= endx; x++)
- X {
- X if(*dstp != *srcp)
- X {
- X gotoxy(lineno,x);
- X Putchar(*srcp);
- X } /* if */
- X *dstp++ = *srcp++;
- X } /* for */
- X twin->_minchng[lineno] = _NO_CHANGE;
- X twin->_maxchng[lineno] = _NO_CHANGE;
- X return ((bool)(_cursvar.refrbrk && _cursespendch()));
- X } /* transformline */
- X
- X/****************************************************************/
- X/* Clearscreen() clears the physical screen and puts the cursor */
- X/* in the home position. */
- X/****************************************************************/
- X
- Xstatic void clearscreen()
- X {
- X _cursesscroll(0,0,LINES-1,COLS-1,0,atrtab[0]);
- X _cursescursor(0,0);
- X _cursvar.cursrow = 0;
- X _cursvar.curscol = 0;
- X } /* clearscreen */
- X
- X/****************************************************************/
- X/* Gotoxy() moves the physical cursor to the desired address on */
- X/* the screen. We don't optimize here - on a PC, it takes more */
- X/* time to optimize than to do things directly. */
- X/****************************************************************/
- X
- Xstatic void gotoxy(row,col)
- X int row, col;
- X {
- X if((_cursvar.cursrow == row) && (_cursvar.curscol == col))
- X return;
- X _cursescursor(row,col);
- X _cursvar.cursrow = row;
- X _cursvar.curscol = col;
- X } /* gotoxy */
- X
- X/****************************************************************/
- X/* Putchar() writes a character, with attributes, to the physi- */
- X/* cal screen, but avoids writing to the lower right screen */
- X/* position. */
- X/****************************************************************/
- X
- Xstatic void Putchar(ch)
- X int ch;
- X {
- X if ((_cursvar.cursrow < LINES) || (_cursvar.curscol < COLS))
- X _cursescattr(ch,atrtab[(ch >> 8) & 0x3f]);
- X } /* Putchar */
- END_OF_update.c
- if test 8693 -ne `wc -c <update.c`; then
- echo \"update.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- echo End of archive 4 \(of 7\).
- cp /dev/null archdone.4
- MISSING=""
- for I in 1 2 3 4 5 6 7 ; do
- if test ! -f archdone.${I} ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 7 archives.
- rm -f archdone.[1-9]
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
-